]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
screenshot: Fix taking interactive screenshots via D-Bus
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 19 Jul 2025 12:12:46 +0000 (14:12 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 1 Aug 2025 14:29:28 +0000 (16:29 +0200)
The D-Bus method relies on the `screenshot-taken` and `closed` signals
to differentiate successful operations from canceled/failed ones.

However as the `screenshot-taken` signal is emitted asynchronously,
it may end up being emitted after the `closed` signal even in case
of success. Await the result to ensure correct ordering.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8499
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3803>
(cherry picked from commit 4272916830120c0ff858e9b9de5d242a04932632)

js/ui/screenshot.js

index afadc7887731a3e9ea2625624929b0daae72460a..058dd1d8a8d6d436c81d784230447bbd1cbdb895 100644 (file)
@@ -1350,7 +1350,7 @@ export const ScreenshotUI = GObject.registerClass({
             visible: false,
         }));
         this._captureButton.connect('clicked',
-            this._onCaptureButtonClicked.bind(this));
+            () => this._onCaptureButtonClicked().catch(logError));
         this._bottomRowContainer.add_child(this._captureButton);
 
         this._showPointerButtonContainer = new St.BoxLayout({
@@ -1872,9 +1872,13 @@ export const ScreenshotUI = GObject.registerClass({
         return [x, y, w, h];
     }
 
-    _onCaptureButtonClicked() {
+    async _onCaptureButtonClicked() {
         if (this._shotButton.checked) {
-            this._saveScreenshot().catch(logError);
+            try {
+                await this._saveScreenshot();
+            } catch (e) {
+                logError(e);
+            }
             this.close();
         } else {
             // Screencast closes the UI on its own.
@@ -2142,7 +2146,7 @@ export const ScreenshotUI = GObject.registerClass({
             symbol === Clutter.KEY_KP_Enter || symbol === Clutter.KEY_ISO_Enter ||
             ((event.get_state() & Clutter.ModifierType.CONTROL_MASK) &&
              (symbol === Clutter.KEY_c || symbol === Clutter.KEY_C))) {
-            this._onCaptureButtonClicked();
+            this._onCaptureButtonClicked().catch(logError);
             return Clutter.EVENT_STOP;
         }